<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="UTF-8">
    <title>MeetSmart - 控制面板</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.0/font/bootstrap-icons.css">
    <!-- 引入自定义CSS -->
    <link rel="stylesheet" th:href="@{/css/style.css}">

    <!-- 引入必要的JS库 -->
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
    <script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/zh.js"></script>

    <!-- 引入自定义JS -->
    <script th:src="@{/js/app.js}"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a class="navbar-brand" href="#">MeetSmart</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link active" href="#"><i class="bi bi-speedometer2"></i> 控制面板</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/rooms}"><i class="bi bi-door-open"></i> 会议室管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/bookings}"><i class="bi bi-calendar-check"></i> 预约管理</a>
                </li>
                <li class="nav-item" sec:authorize="hasRole('ADMIN')">
                    <a class="nav-link" th:href="@{/users}"><i class="bi bi-people"></i> 用户管理</a>
                </li>
                <li class="nav-item" sec:authorize="hasRole('ADMIN')">
                    <a class="nav-link" th:href="@{/reports}"><i class="bi bi-graph-up"></i> 统计报表</a>
                </li>
            </ul>
            <ul class="navbar-nav">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown">
                        <i class="bi bi-person-circle"></i> <span sec:authentication="name"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <li><a class="dropdown-item" th:href="@{/profile}"><i class="bi bi-person"></i> 个人资料</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <form th:action="@{/logout}" method="post">
                                <button type="submit" class="dropdown-item"><i class="bi bi-box-arrow-right"></i> 退出登录</button>
                            </form>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

<div class="container mt-4">
    <h2><i class="bi bi-speedometer2"></i> 欢迎回来, <span sec:authentication="name"></span>!</h2>

    <div class="row mt-4">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5><i class="bi bi-calendar-event"></i> 当前会议</h5>
                </div>
                <div class="card-body">
                    <div th:if="${currentBookings.empty}" class="alert alert-info">
                        当前没有正在进行的会议
                    </div>
                    <div th:each="booking : ${currentBookings}" class="mb-3 p-2 border rounded">
                        <h6><i class="bi bi-bookmark"></i> <span th:text="${booking.title}"></span></h6>
                        <p><i class="bi bi-door-open"></i> 会议室: <span th:text="${booking.room.name}"></span></p>
                        <p><i class="bi bi-clock"></i> 时间:
                            <span th:text="${#temporals.format(booking.startTime, 'yyyy-MM-dd HH:mm')}"></span> -
                            <span th:text="${#temporals.format(booking.endTime, 'HH:mm')}"></span>
                        </p>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5><i class="bi bi-lightning-charge"></i> 快捷操作</h5>
                </div>
                <div class="card-body">
                    <a th:href="@{/bookings/new}" class="btn btn-primary mb-2"><i class="bi bi-plus-circle"></i> 新建预约</a>
                    <a th:href="@{/rooms}" class="btn btn-secondary mb-2"><i class="bi bi-search"></i> 查看会议室</a>
                    <a sec:authorize="hasRole('ADMIN')" th:href="@{/rooms/new}" class="btn btn-success mb-2"><i class="bi bi-plus-lg"></i> 添加会议室</a>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>